package com.foreknow.dao.impl;

import com.foreknow.dao.GuestbookDao;
import com.foreknow.mapping.EntityMapping;
import com.foreknow.mapping.MappingFactory;
import com.foreknow.model.Guestbook;

import java.util.List;

public class GuestbookDaoImpl extends BaseDao implements GuestbookDao {
    @Override
    public List<Object> getQueryAll() {
        String sql = "select * from guestbook";
        EntityMapping mapping = mappingFactory.getMapping(MappingFactory.GUESTBOOK_MAPPING);
        List<Object> list = jdbcTemplate.query(sql,mapping);
        return list;
    }

    @Override
    public boolean delete(int id) {
        String sql = "delete from guestbook where id = ?";
        int isRight = jdbcTemplate.update(sql,id);
        return isRight == 1;
    }
}
